package com.wnhz.work.jy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wnhz.work.jy.R;
import com.wnhz.work.jy.bean.LogisticsBean;

import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by d on 2016/10/31.
 */

public class LogisticsAdapter extends BaseAdapter {
    private Context context;
    private List<LogisticsBean> list;

    public LogisticsAdapter(Context context, List<LogisticsBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyHolder holder;
        if (convertView == null){
            holder = new MyHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_logistics,null);
            holder.view = convertView.findViewById(R.id.view);
            holder.index_img = (ImageView) convertView.findViewById(R.id.index_img);
            holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
            holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
            convertView.setTag(holder);
        }
        holder = (MyHolder) convertView.getTag();
        if (position == 0){
            holder.view.setBackgroundColor(0xffffffff);
            holder.index_img.setImageResource(R.mipmap.ic_wuliushijianzhou_li);
            holder.tv_content.setTextColor(0xffe2bb0a);
        }else {
            holder.view.setBackgroundColor(0x00ffffff);
            holder.index_img.setImageResource(R.mipmap.ic_wuliushijianzhou_nor);
            holder.tv_content.setTextColor(0xff999999);
        }
        holder.tv_content.setText(list.get(position).getAcceptStation());
        holder.tv_time.setText(list.get(position).getAcceptTime());
        return convertView;
    }

    private class MyHolder{
        View view;
        ImageView index_img;
        TextView tv_content;
        TextView tv_time;
    }
}
